//
//  WechatOpenSDKSwift.swift
//  Pods-WechatOpenSDKSwift_Example
//
//  Created by Li on 2020/6/3.
//

import Foundation

public class WechatOpenSDKSwift {
    public class func regist(appId:String, universalLink: String) {
        WXApi.registerApp(appId, universalLink: universalLink)
    }
    
    public class func handleURL(url:URL)->Bool {
        return WXApi.handleOpen(url, delegate: WXApiManager.shared())
    }
    
    public class func handleOpenUniversalLink(userActivity:NSUserActivity )->Bool  {
        return WXApi.handleOpenUniversalLink(userActivity, delegate: WXApiManager.shared())
    }
    
    public class func isWXAppInstalled()->Bool {
        return WXApi.isWXAppInstalled()
    }

    public class func sendLoginMessage(callBack:@escaping  ((Bool)->Void)) {

        let request = SendAuthReq()
        request.state = "1234"
        request.scope = "snsapi_userinfo"
        WXApi.send(request) { (complete) in
            callBack(complete)
        }
    }
    
    public class func setDelegate(delegate:WXApiManagerDelegate) {
        WXApiManager.shared()?.delegate = delegate
    }
}
